<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>轮播图管理 | {$system_name}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="{_ADMIN_STATIC_}/i/favicon.png">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/amazeui.min.css" />
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/admin.css">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/app.css">

</head>

<body data-type="index">
    <!-- 头部导航栏 -->
    {include file='public/header'}
    <!-- 左侧侧边栏 -->
    {include file='public/side'}
    <!-- 中间内容开始 -->

    <!-- 标题 -->
    <div class="tpl-content-page-title">
        {$system_name} -- 轮播图管理
    </div>
    <!-- 面包屑导航 -->
    <ol class="am-breadcrumb">
        <li><i class="am-icon-home"></i>轮播图管理</li>
    </ol>
    <!-- 提示信息 -->
    <div class="tpl-content-scope">
        <div class="note note-info">
            <h3> 轮播图管理
                <span class="close" data-close="note"></span>
            </h3>
            <p>轮播图管理</p>
            <p><span class="label label-danger">提示:</span>
                前端首页的轮播图 最大数量：【{$slideshow_max_size}】
            </p>
        </div>

        <div class="tpl-portlet-components">
            {if condition="$is_add_slideshow"}
            <div class="am-btn-group am-btn-group-xs">
                <button type="button" class="am-btn am-btn-default am-btn-success" onclick="slideshow_add()"><span
                        class="am-icon-plus"></span>
                    新增轮播图</button>
            </div>
            {/if}

            <div>
                <!-- 具体的表格内容 -->
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                        <tr>
                            <th class="table-id" style='vertical-align: middle;text-align: center;'>#</th>
                            <th class="table-title" style='vertical-align: middle;text-align: center;'>轮播图的标题</th>
                            <th class="table-author" style='vertical-align: middle;text-align: center;'>图片</th>
                            <th class="table-type" style='vertical-align: middle;text-align: center;'>链接的文章</th>
                            <th class="table-title" style='vertical-align: middle;text-align: center;'>轮播图的状态</th>
                            <th class="table-date" style='vertical-align: middle;text-align: center;'>更新时间</th>
                            <!-- <th class="table-date" style='vertical-align: middle;text-align: center;'>创建时间</th> -->
                            <th class="table-set" style="width: 145px;vertical-align: middle;text-align: center;">操作
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        {volist name="slideshow_info" id="row" empty="$empty"}
                        <tr>
                            <td style='vertical-align: middle;text-align: center;'>{$row.id}</td>
                            <td style='vertical-align: middle;text-align: center;'>{$row.title}</td>
                            <td style='vertical-align: middle;text-align: center;'>
                                <img src="/storage/{$row.img_path}" style="width: 100px;height: 50px;">
                            </td>
                            <td style='vertical-align: middle;text-align: center;'>{$row.notice_name}</td>
                            <td style='vertical-align: middle;text-align: center;'>
                                {if condition="$row.status == 2"}
                                <span style="color: green;">已启用</span>
                                {else /}
                                <span style="color: red;">已禁用</span>
                                {/if}
                            </td>
                            <td style='vertical-align: middle;text-align: center;'>{$row.update_time | date='Y-m-d H:i:s'}
                            </td>

                            <td style='vertical-align: middle;text-align: center;'>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                            onclick="edit('{$row.id}')"><span class="am-icon-pencil-square-o"></span>
                                            编辑</button>
                                        <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"
                                            onclick="del('{$row.id}')"><span class="am-icon-trash-o"></span>
                                            删除</button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        {/volist}

                    </tbody>
                </table>
            </div>
            <!-- 加载分页组件 -->


        </div>
    </div>


    <!-- 中间内容结束 -->

    <script src="{_ADMIN_STATIC_}/lib/jquery/jquery.js"></script>
    <script src="{_ADMIN_STATIC_}/js/amazeui.min.js"></script>
    <script src="{_ADMIN_STATIC_}/js/app.js"></script>
    <script src="{_ADMIN_STATIC_}/lib/layer/layer.js"></script>
    <script>

        // 添加轮播图页面
        function slideshow_add() {
            redirect_url("{:url('Slideshow/add')}");
        }

        // 编辑轮播图
        function edit(id) {
            redirect_url("{:url('Slideshow/edit')}?id=" + id);
        }

        // 删除轮播图
        function del(id) {
            layer.confirm('是否确认删除？', {

                btn: ['是', '否'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('Slideshow/del_slideshow')}",
                    data: {
                        'id': id
                    },
                    type: "POST",
                    dataType: "JSON",
                    success: function (res) {
                        // 返回结果处理
                        if (res.code == 0) {
                            return layer.msg(res.msg, { icon: 1, time: 900 },function(){
                                location.reload();
                            });
                        } else {
                            return layer.msg(res.msg, { icon: 2, time: 900 });
                        }
                    },
                    error: function (data) {
                        return layer.msg("服务器异常，请检查", { icon: 2, time: 900 });
                    }
                });




            }, function () { });
        }

        // 重定向
        function redirect_url(url) {
            window.location.href = url;
        }

    </script>
</body>

</html>